<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateNodesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('nodes', function (Blueprint $table) {
            $table->id();

            $table->string('name','50')->default('未知')->comment('节点名称');

            //权限控制通过 路由别名 进行控制
            $table->string('route_name',50)->default('未知')->comment('路由别名');

            //父级id 控制菜单层级
            $table->unsignedInteger('pid')->default(0)->comment('父级id');;

            //因为要控制到按钮权限，所以 要确定路由别名是否为菜单
            $table->unsignedTinyInteger('is_menu')->default(0)->comment('是否为菜单，0:不是，1：是');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('nodes');
    }
}
